$(document).ready(function() { 
        $('input.button').click(function() { 
            showLoader();
        });
        
        $('a.preloader').click(function() { 
            showLoader();
        });
 
}); 

function showLoader () {
	var loadingPanelZIndex = 120000;
	var transparency = 30; // In percentage;
	
	$("body").append("<div id='loading'><img id='loading_anim' src='./img/loadingAnimation.gif' /></div>");
	
	var loadPan = document.getElementById("loading");
	var anim = document.getElementById("loading_anim");
   
	var opacity = 100 - parseInt(transparency);
   
	loadPan.style.position = "absolute";
	loadPan.style.width = document.body.scrollWidth + "px";
	loadPan.style.height = (document.body.scrollHeight - 10) + "px";
	loadPan.style.left = "0px";
	loadPan.style.top = "0px";
	loadPan.style.textAlign = "center";
	loadPan.style.padding = "0px";
	loadPan.style.zIndex = loadingPanelZIndex;
	loadPan.style.backgroundColor = "#000";
	loadPan.style.MozOpacity = opacity / 100;
	loadPan.style.filter = "alpha(opacity=" + opacity + ")";
	
	var scrlTop = document.documentElement.scrollTop || document.body.scrollTop;
	var topPosition = scrlTop + document.body.clientHeight/2 - anim.height;

	anim.style.marginTop = topPosition + "px";
	anim.style.zIndex = 120001;
	
};

function hideLoader (contentPanId, loadPanId) {
var loadPan = document.getElementById(loadPanId);
var contentPan = document.getElementById(contentPanId);
contentPan.style.display = '';
loadPan.style.display = 'none';
}

function show(id){
  document.getElementById(id).style.visibility = "visible";
}

function hide(id) {
  document.getElementById(id).style.visibility = "hidden";
}

function changeVisibility(elementName) {
  field = document.getElementById(elementName);
  $(field).toggle();
};

function MyTip(tag, type) {
    switch(type) {
      case "help":
        TagToTip(tag, ABOVE, true, FADEIN, 200);
    }
};

function MakeLink() {
  var sel = document.getElementById("foto")
  var name = sel.options[sel.selectedIndex].value
  document.getElementById("odkaz").value="index.php?page=23&menu=6&album="+name
};

function MakeVideoPlayer(id_video) {
  document.getElementById("video_tag").value="<p class=\"video-player\" id=\"video"+id_video+"\"></p>"
};

function createTinyMCEOptimalization() {
  tinyMCE_GZ.init({
  	plugins : 'style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,'+ 
          'searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras',
  	themes : 'simple,advanced',
  	languages : 'cs',
  	disk_cache : true,
  	debug : false
  });
}

function createSimpleWysiwyg(id) {
  tinyMCE.init({
	// General options
		mode : "exact",
		elements: id,
		theme : "advanced",
		skin : "o2k7",
		skin_variant : "black",
		
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist",
		theme_advanced_buttons2 : "",
		
		content_css : "./css/tinymce.css"

  });
}

function createAdvancedWysiwyg(id) {
  tinyMCE.init({
	// General options
		mode : "exact",
		elements: id,
		theme : "advanced",
		skin : "o2k7",
		skin_variant : "black",
		
		plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,formatselect,fontselect,fontsizeselect,|,link,unlink,anchor,image,cleanup,help,code,|,charmap,emotions,iespell,media,advhr",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,outdent,indent,blockquote,|,insertdate,inserttime,preview,|,forecolor,backcolor,|tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,|,ltr,rtl,|,fullscreen,|,undo,redo",
		theme_advanced_buttons3 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true,
		
		content_css : "./css/tinymce.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		template_replace_values : {
			username : "Flashman",
			staffid : "991234"
		}
  });
}

function createForumWysiwyg(id) {
  tinyMCE.init({
	// General options
		mode : "exact",
		elements: id,
		theme : "advanced",
		skin : "o2k7",
		skin_variant : "black",
		
		plugins : "safari,pagebreak,style,table,save,advhr,advimage,advlink,emotions,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",

		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,|,bullist,numlist,|,link,unlink,|,forecolor,emotions",
		theme_advanced_buttons2 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "none",
		theme_advanced_resizing : true,
		
		content_css : "./css/tinymce.css",

		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",

		// Replace values for the template plugin
		template_replace_values : {
			username : "Flashman",
			staffid : "991234"
		}
  });
}
